package com.tdkj.service;

import java.util.LinkedHashMap;
import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Query;

import com.tdkj.dao.BaseDao;
import com.tdkj.model.base.BaseEntity;
import com.tdkj.util.Page;

public interface IBaseService {
	
	//虚拟币种类
	enum VirtualCurrencyType{
		金币("金币"),银币("银币"),矿币("矿币");
		private String chineseName;
		private VirtualCurrencyType(String chineseName){
			this.chineseName = chineseName;
		}
		public String getChineseName(){
			return this.chineseName;
		}
		public String getName(){
			return this.name();
		}
		
	}
	
	//虚拟币种类
	enum TimeUnit{
		年("年"),月("月"),天("天"),小时("小时");
		private String chineseName;
		private TimeUnit(String chineseName){
			this.chineseName = chineseName;
		}
		public String getChineseName(){
			return this.chineseName;
		}
		public String getName(){
			return this.name();
		}
	}

	public void setBaseDao(BaseDao baseDao);

	public void save(BaseEntity bean);

	public void delete(BaseEntity bean);

	public void delete(Long id, Class<? extends BaseEntity> clazz);

	public void delete(String propertyName, Object value, Class<? extends BaseEntity> clazz);

	public <T extends BaseEntity> T findById(long id, Class<T> clazz);

	public <T extends BaseEntity> List<T> findByExample(T t);

	public <T extends BaseEntity> List<T> findByExample(T t, LinkedHashMap<String, String> orderInfos);

	public <T extends BaseEntity> List<T> findByExample(T t, String orderByPropertyName, String orderByType);

	public <T extends BaseEntity> List<T> findByProperty(String propertyName, Object value, Class<T> clazz);

	public <T extends BaseEntity> List<T> findByProperty(String propertyName, Object value, Class<T> clazz, LinkedHashMap<String, String> orderInfos);

	public <T extends BaseEntity> List<T> findByProperty(String propertyName, Object value, Class<T> clazz, String orderByPropertyName, String orderByType);

	public <T extends BaseEntity> List<T> findAll(Class<T> clazz);
	/**
	 * 
	 * @param <T>
	 * @param clazz
	 * @param index 开始
	 * @param suffix 数量
	 * @return
	 */
	public <T extends BaseEntity> List<T> findAll(Class<T> clazz,int index,int count);
	
	/**
	 * 只获取一条记录  对应数据库中只有一打数据的表
	 * @param <T>
	 * @param clazz
	 * @return
	 */
	public <T extends BaseEntity> T findEntity(Class<T> clazz);

	public <T extends BaseEntity> List<T> findAll(Class<T> clazz, LinkedHashMap<String, String> orderInfos);

	public <T extends BaseEntity> List<T> findAll(Class<T> clazz, String orderByPropertyName, String orderByType);

	public <T extends BaseEntity> T merge(T bean);

	public void attachDirty(BaseEntity bean);

	public void attachClean(BaseEntity bean);

	public boolean isExist(long id, Class<? extends BaseEntity> clazz);

	public void saveOrUpdate(BaseEntity bean, Class<? extends BaseEntity> clazz);

	BaseDao getBaseDao();

	public Page findBy(Query query, int pageNumber, int pageSize);

	public Page findBy(Criteria criteria, int pageNumber, int pageSize);

	public Page findPageBy(Criteria criteria, int pageNumber, int pageSize);
	
	Page findBy(String sql, int pageNumber, int pageSize);
	
	List<Object> findBySql(String sql);

}
